#include<stdio.h>
#include<stdlib.h>
int main()
{
	int M, N, K;
	scanf("%d %d %d", &M, &N, &K);
	int i, j;
	int a[K][N];
	int t = 0;
	int flag = 0;
	for (i = 0; i < K; i++)
	{
		for (j = 0; j < N; j++)
		{
			scanf("%d", &a[i][j]);
		}
	}
	for (i = 0; i < K; i++)
	{
		for (j = 0; j < N;)
		{
			if (a[i][j] > M + j) {
				flag = 1;
				break;
			}
			else j++;
		}
		while (!flag) {
			t = a[i][0];
			for (j = 1; j < N - 1;)
			{
				if (a[i][j] < a[i][j - 1] && a[i][j] < a[i][j + 1] && a[i][j + 1] < t)
				{
					flag = 1;
					break;
				}
				else if (a[i][j] > a[i][j - 1]) {
					t = a[i][j];
					j++;
				}
				else j++;
			}
			break;
		}
		if (flag == 1)printf("NO\n");
		else printf("YES\n");
		flag = 0;
	}
}
